import Vue from 'vue';
import App from './App.vue';
import router from './router';
import ElementUI from 'element-ui';
// import VueI18n from 'vue-i18n';
// import {
//     messages
// } from './views/common/i18n';
import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
// import './assets/css/theme-green/index.css'; // 浅绿色主题
import './assets/css/icon.css';
import './views/common/directives';
import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import 'babel-polyfill';


import store from './store'
import moment from 'moment'

import Pagination from "@/components/Pagination";
import RightToolbar from "@/components/RightToolbar"
import tableHeight from '@/directive/tableHeight/index'
import permission from '@/directive/permission/index'
// import {
//     has
// } from '@/directive/permission/index'

import areaData from '@/assets/json/areaData'
import nationList from '@/assets/json/nation'
import SvgIcon from '@/components/SvgIcon'
import {
    parseTime,
    resetForm,
    addDateRange,
    selectDictLabel,
    selectDictLabels,
    download,
    handleTree,
    onInput,
    onInput1,
    handleNum,
    handleNum0,
    isEmpty,
    getToday,
    getNowMonth,
    clearBlack,
    limitFileWH,
    limitFileRate
} from "@/utils/ruoyi";


Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.onInput = onInput;
Vue.prototype.onInput1 = onInput1;
Vue.prototype.handleNum = handleNum;
Vue.prototype.handleNum0 = handleNum0;
Vue.prototype.isEmpty = isEmpty;
Vue.prototype.getToday = getToday;
Vue.prototype.getNowMonth = getNowMonth
Vue.prototype.areaData = areaData;
Vue.prototype.clearBlack = clearBlack
Vue.prototype.limitFileWH = limitFileWH
Vue.prototype.limitFileRate = limitFileRate
Vue.prototype.nationList = nationList;
Vue.prototype.$moment = moment

// Vue.prototype.$uploadUrl = 'https://yl.weilankangyang.com/api/common/fileUpload'; //上传正式地址
Vue.prototype.$uploadUrl = 'https://betayl.weilankangyang.com/api/common/fileUpload';//上传测试地址
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('svg-icon', SvgIcon)
const req = require.context('@/assets/icons/svg', false, /\.svg$/)
const requireAll = requireContext => requireContext.keys().map(requireContext)
requireAll(req)

Vue.prototype.msgSuccess = function (msg) {
    this.$message({
        showClose: true,
        message: msg,
        type: "success"
    });
}

Vue.prototype.msgError = function (msg) {
    this.$message({
        showClose: true,
        message: msg,
        type: "error"
    });
}

Vue.prototype.msgInfo = function (msg) {
    this.$message.info(msg);
}

Vue.config.productionTip = false;
// Vue.use(VueI18n);
Vue.use(ElementUI, {
    size: 'small'
});
Vue.use(tableHeight)
Vue.use(permission)
// Vue.use(has)

// const i18n = new VueI18n({
//     locale: 'zh',
//     messages
// });

// 使用钩子函数对路由进行权限跳转
// router.beforeEach((to, from, next) => {
//     document.title = `${to.meta.title}`;
//     const role = localStorage.getItem('ms_username');
//     if (!role && to.path !== '/login') {
//         next('/login');
//     } else if (to.meta.permission) {
//         如果是管理员权限则可进入，这里只是简单的模拟管理员权限而已
//         role === 'admin' ? next() : next('/403');
//     } else {
//         简单的判断IE10及以下不进入富文本编辑器，该组件不兼容
//         if (navigator.userAgent.indexOf('MSIE') > -1 && to.path === '/editor') {
//             Vue.prototype.$alert('vue-quill-editor组件不兼容IE10及以下浏览器，请使用更高版本的浏览器查看', '浏览器不兼容通知', {
//                 confirmButtonText: '确定'
//             });
//         } else {
//             next();
//         }
//     }
// });

// 环信
// import websdk from "easemob-websdk"
// Vue.use(websdk);
import Antd from './utils/antd-vue';
import WebIM from './utils/WebIM/WebIM';
import Router from 'vue-router';
Vue.config.productionTip = false;
Vue.use(Antd);
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location){
	return originalPush.call(this, location)['catch'](err => err);
};

// var conn = {};
// WebIM.config = config;
// var options = {
//     apiUrl: WebIM.config.apiURL,
//     user: '',
//     pwd: '',
//     appKey: WebIM.config.appkey,
//     success: function (res) {
//         console.log(res)
//         console.log('成功')
//     },
//     error: function (err) {
//         console.log(err)
//     }
// };
// Vue.prototype.$conn = conn;
// Vue.prototype.$login = options; //登录 

new Vue({
    router,
    // components: { App },
	// template: '<App/>',
    store,
    // i18n,
    WebIM,
    render: h => h(App)
}).$mount('#app');